$(function(){
    $('#discuss-box').keydown(function(event){
        //当点击回车时
        if(event.keyCode == 13){
            //alert('enter');
            var content = $(this).val();
            if($.trim(content) == ''){
                layer.msg('聊天内容不能为空');
            }
            var url = "http://swoole.kinggui.com:8811/index/Chat/index";
            var data = {content: content, game_id : 1};
            $.post(url, data, function (data) {
                if(data.status == 1){
                    //发送成功后，将表单清空
                    $('#discuss-box').val('');
                    layer.msg(data.message);
                }else{
                    layer.msg(data.message);
                }
            },'json');
        }
    });
});